package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Add implements Ioperation{

    @Override
    public void work(BookList bookList) {
        int pos = bookList.getCur();
        if(pos == bookList.getCount()){
            System.out.println("书架已满，无法增加......");
            return;
        }

        Scanner scan = new Scanner(System.in);
        System.out.println("请输入增加的书名：");
        String name = scan.nextLine();
        System.out.println("请输入作者：");
        String author = scan.nextLine();
        System.out.println("输入书的类型：");
        String type = scan.nextLine();
        System.out.println("输入价格：");
        double price = scan.nextDouble();

        Book newBook = new Book(name,author,price,type);
        bookList.setBooks(pos,newBook);
        bookList.setCur(pos + 1);
    }
}
